package cn.dapeng.thread;

import cn.dapeng.util.SleepingUtil;

import java.util.concurrent.TimeUnit;

/**
 * @BelongProject study
 * @BelongPackage cn.dapeng.thread
 * @Description TODO
 * @ClassName Thread_Volatile_T01
 * @Author xupenghong
 * @Date 2024/8/19 16:46
 * @Version 1.0.0
 */
public class Thread_Volatile_T01 {

    public static volatile boolean running = true;

    public static void main(String[] args) {
        new Thread(() -> {
            System.out.println("start");
            while (running) {
            }
            System.out.println("end");
        }).start();
        SleepingUtil.sleep(1, TimeUnit.SECONDS);
        running = false;
    }


}
